package com.flurry.android;

import android.text.TextUtils;
import android.util.Log;
import java.util.HashMap;
import java.util.Iterator;
import java.util.LinkedList;
import java.util.List;
import java.util.Map.Entry;
import java.util.Set;
import java.util.Timer;

final class bv
{
  private HashMap<String, ac> Y = new HashMap();
  private boolean dM = false;
  private long dN = 30000L;
  private String mCollectionName = null;
  private String mId = null;

  bv(String paramString)
  {
    this.mId = paramString;
    this.mCollectionName = null;
  }

  bv(String paramString1, String paramString2)
  {
    this.mId = paramString1;
    this.mCollectionName = paramString2;
  }

  private long a(int paramInt)
  {
    if (paramInt == 0)
      return 0L;
    return this.dN;
  }

  private void an()
  {
    Iterator localIterator = this.Y.entrySet().iterator();
    while (localIterator.hasNext())
      j((String)((Map.Entry)localIterator.next()).getKey());
  }

  private void ao()
  {
    Iterator localIterator = this.Y.entrySet().iterator();
    while (localIterator.hasNext())
      i((String)((Map.Entry)localIterator.next()).getKey());
  }

  private void i(String paramString)
  {
    if (((ac)this.Y.get(paramString)).bS == null)
      return;
    ac localac = (ac)this.Y.get(paramString);
    if (localac == null)
    {
      Log.e("ObserverItem", "stopTimerForKey ERROR, info == null");
      return;
    }
    if (localac.bS != null)
    {
      localac.bS.cancel();
      localac.bS = null;
    }
    this.Y.put(paramString, localac);
  }

  private void j(String paramString)
  {
    a(paramString, Long.valueOf(a(0)));
  }

  protected final void a(String paramString, Long paramLong)
  {
    i(paramString);
    if (!this.dM)
      return;
    ac localac = (ac)this.Y.get(paramString);
    if (localac == null)
    {
      Log.e("ObserverItem", "scheduleTimerForKey ERROR, info == null");
      return;
    }
    localac.bS = new Timer();
    gf localgf = new gf(this, paramString);
    Log.i("ObserverItem", "schedule");
    localac.bS.schedule(localgf, paramLong.longValue());
    this.Y.put(paramString, localac);
  }

  public final boolean a(Object paramObject)
  {
    Iterator localIterator = this.Y.entrySet().iterator();
    boolean bool1 = false;
    if (localIterator.hasNext())
    {
      List localList = ((ac)((Map.Entry)localIterator.next()).getValue()).bT;
      if (!localList.contains(paramObject))
        break label93;
      localList.remove(paramObject);
      if (localList.size() == 0)
        localIterator.remove();
    }
    label93: for (boolean bool2 = true; ; bool2 = bool1)
    {
      bool1 = bool2;
      break;
      return bool1;
    }
  }

  public final void al()
  {
    this.dM = true;
    an();
  }

  public final void am()
  {
    this.dM = false;
    ao();
  }

  protected final void b(String paramString, Object paramObject)
  {
    ac localac;
    if (this.Y.containsKey(paramString))
    {
      localac = (ac)this.Y.get(paramString);
      if (localac == null)
        Log.e("ObserverItem", "addObserverForKey ERROR, info == null");
    }
    while (true)
    {
      return;
      localac.bT.add(paramObject);
      this.Y.put(paramString, localac);
      while (this.dM)
      {
        j(paramString);
        return;
        LinkedList localLinkedList = new LinkedList();
        localLinkedList.add(paramObject);
        this.Y.put(paramString, new ac(localLinkedList));
      }
    }
  }

  public final void b(String paramString1, String paramString2)
  {
    if (this.Y.containsKey(paramString1))
    {
      Iterator localIterator = ((ac)this.Y.get(paramString1)).bT.iterator();
      while (localIterator.hasNext())
      {
        Object localObject = localIterator.next();
        if ((localObject instanceof FlurryWalletHandler))
        {
          FlurryWalletHandler localFlurryWalletHandler = (FlurryWalletHandler)localObject;
          FlurryWalletInfo localFlurryWalletInfo = new FlurryWalletInfo();
          localFlurryWalletInfo.iv = paramString1;
          localFlurryWalletInfo.iw = Float.parseFloat(paramString2);
          localFlurryWalletHandler.onValueUpdated(localFlurryWalletInfo);
        }
        else if ((localObject instanceof AppCloudValueUpdateHandler))
        {
          ((AppCloudValueUpdateHandler)localObject).onValueUpdated(paramString1);
        }
        else
        {
          Log.e("ObserverItem", "CALLBACK ERROR!");
        }
      }
    }
  }

  public final boolean isAutoSyncEnabled()
  {
    return this.dM;
  }

  protected final void k(String paramString)
  {
    ac localac = (ac)this.Y.get(paramString);
    if (localac == null)
    {
      Log.e("ObserverItem", "addObserverForKey ERROR, info == null");
      return;
    }
    localac.G = (1 + localac.G);
    long l = a(localac.G);
    this.Y.put(paramString, localac);
    if (TextUtils.isEmpty(this.mCollectionName))
    {
      AppCloudUser localAppCloudUser = new AppCloudUser();
      localAppCloudUser.setId(this.mId);
      try
      {
        localAppCloudUser.getObjectOrUser(new bf(this, paramString, l));
        return;
      }
      catch (Exception localException1)
      {
        localException1.printStackTrace();
        return;
      }
    }
    AppCloudObject localAppCloudObject = AppCloudObject.create(this.mCollectionName);
    localAppCloudObject.setId(this.mId);
    try
    {
      localAppCloudObject.getObjectOrUser(new bd(this, paramString, l));
      return;
    }
    catch (Exception localException2)
    {
      localException2.printStackTrace();
    }
  }

  protected final boolean removeObserverForKey(String paramString)
  {
    if (!this.Y.containsKey(paramString))
      return false;
    i(paramString);
    this.Y.remove(paramString);
    return true;
  }

  public final int size()
  {
    return this.Y.size();
  }

  final void start()
  {
    if (this.dM)
      an();
  }

  final void stop()
  {
    ao();
  }
}

/* Location:           E:\android\Toy Defense 2_dex2jar.jar
 * Qualified Name:     com.flurry.android.bv
 * JD-Core Version:    0.6.2
 */